<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:cms="http://thymeleafexamples">
<head th:include="include/head">

</head>
<style>
    .content-wrapper, .main-footer, .main-header{
        margin-left: 0;
    }
</style>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">


    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>活动列表</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">首页</a></li>
                            <li class="breadcrumb-item active">活动列表</li>
                        </ol>
                    </div>
                </div>
            </div>
            <!-- /.container-fluid -->
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <h3 class="card-title">活动列表</h3>
                                <button type="button" class="btn btn-primary btn-sm" id="add" style="float: right">新增</button>
                            </div>
                            <div class="card-header">
                                <form id="search-form2" class="navbar-form form-inline"  th:action="@{/activity/activityList}" method="post">

                                    <div class="form-group " >
                                        <label>活动主题:</label>
                                        <div class="col-sm-4" >
                                            <input type="text" name="name" th:value="${name}" placeholder="活动主题" class="form-control">
                                        </div>
                                    </div>

<!--                                    <div class="form-group " >-->
<!--                                        <label>学院:</label>-->
<!--                                        <div class="col-sm-2" >-->
<!--                                            <select  class="form-control"   id="collegeId" name="collegeId" >-->
<!--                                                <option value=>全部</option>-->
<!--                                                <option   value=0 th:selected="0==${collegeId}">林学院</option>-->
<!--                                                <option   value=1 th:selected="1==${collegeId}">材料科学与工程学院</option>-->
<!--                                                <option   value=2 th:selected="2==${collegeId}">野生动物与自然保护地学院</option>-->
<!--                                                <option   value=3 th:selected="3==${collegeId}">工程技术学院</option>-->
<!--                                                <option   value=4 th:selected="4==${collegeId}">机电工程学院</option>-->
<!--                                                <option   value=5 th:selected="5==${collegeId}">生命科学学院</option>-->
<!--                                                <option   value=6 th:selected="6==${collegeId}">园林学院</option>-->
<!--                                                <option   value=7 th:selected="7==${collegeId}">土木工程学院</option>-->
<!--                                                <option   value=8 th:selected="8==${collegeId}">交通学院</option>-->
<!--                                                <option   value=9 th:selected="9==${collegeId}">信息与计算机工程学院</option>-->
<!--                                                <option   value=10 th:selected="10==${collegeId}">理学院</option>-->
<!--                                                <option   value=11 th:selected="11==${collegeId}">化学化工与资源利用学院</option>-->
<!--                                                <option   value=12 th:selected="12==${collegeId}">经济管理学院</option>-->
<!--                                                <option   value=13 th:selected="13==${collegeId}">文法学院</option>-->
<!--                                                <option   value=14 th:selected="14==${collegeId}">外国语学院</option>-->
<!--                                                <option   value=15 th:selected="15==${collegeId}">马克思主义学院</option>-->
<!--                                                <option   value=16 th:selected="16==${collegeId}">奥林学院</option>-->
<!--                                                <option   value=17 th:selected="17==${collegeId}">体育部</option>-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                    <div class="form-group " >-->
<!--                                        <label>发起人:</label>-->
<!--                                        <div class="col-sm-2" >-->
<!--                                            <select  class="form-control"   id="userName" name="userName" >-->
<!--                                                <option value="">全部</option>-->
<!--                                                <div th:each="userName : ${userNameList}">-->
<!--                                                    &lt;!&ndash;theSelectedUserName之前查询时选中的活动发起人的姓名&ndash;&gt;-->
<!--                                                    <option th:value="${userName}" th:selected="${theSelectedUserName}==${userName}">-->
<!--                                                        <text th:text="${userName}"></text>-->
<!--                                                    </option>-->
<!--                                                </div>-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->
                                    <div class="form-group " >
                                        <label>状态:</label>
                                        <div class="col-sm-2" >
                                            <select  class="form-control"  id="activityState;" name="activityState" >
                                                <option value=>全部</option>
                                                <option value=0 th:selected="0==${activityState}">未开始</option>
                                                <option value=1 th:selected="1==${activityState}">报名中</option>
                                                <option value=2 th:selected="2==${activityState}">进行中</option>
                                                <option value=3 th:selected="3==${activityState}">已结束</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group " >
                                        <button type="button" id="serch"  style="font-size:0.5rem;" class="btn btn-primary pull-right">查询</button>
                                    </div>
                                </form>

                            </div>
                            <!-- /.card-header -->
                            <div class="card-body">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <!-- 												<th style="width: 10px">#</th> -->
                                        <th>活动id</th>
                                        <th>活动主题</th>
                                        <th>状态</th>
<!--                                        <th>内容</th>-->
<!--                                        <th>创建时间</th>-->
                                        <th style="width: 250px">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody id="content">
                                    <tr th:each="bean : ${pageInfo.list}" th:attr="id=tr_+${bean.activityId}">
                                        <td th:text="${bean.activityId}"></td>
                                        <td th:text="${bean.activityName}">
                                        <td th:switch="${bean.activityState}">
<!--                                        1 未开始  2报名中  3进行中  4已结束-->

                                            <span th:case="0">未开始</span>
                                            <span th:case="1">报名中</span>
                                            <span th:case="2">进行中</span>
                                            <span th:case="3">已结束</span>
                                        </td>
                                        <td>
<!--                                            th:href="'majorDetail?MajorId='+${bean.majorId}"-->
                                            <a th:href="'activityDetail?activityId='+${bean.activityId}" class="btn btn-info btn-sm">
                                                <i class="fas fa-pencil-alt"></i>详情
                                            </a>
<!--                                            <a th:href="'activityEdit?activityId='+${bean.activityId}" class="btn btn-info btn-sm">-->
<!--                                                <i class="fas fa-pencil-alt"></i>编辑-->
<!--                                            </a>-->
                                            <a href="javascript:;" th:attr="data-id=|${bean.activityId}" class="btn btn-danger btn-sm del">
                                                <i class="fas fa-trash"></i>删除
                                            </a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <cms:page></cms:page>
                        </div>

                    </div>
                </div>
            </div>
        </section>
    </div>
</div>
<!-- ./wrapper -->
<div th:include="include/foot"></div>
<script>
    $("#hospitalId").change(function (){
        let v=$(this).val();
        let t= $(this).find("option:selected").text();
        console.log(v,t)
        if(v>0){
            $("#hospitalName").val(t);
        }
        $.ajax({url:'../doctor/departmentList',data:"hospitalId="+v,success:function (data){
                if(data.res){
                    $("#dpId").empty();
                    $("#dpId").append("<option value=''>请选择科室</option>");
                    for(let i=0;i<data.list.length;i++){
                        console.log(data.list[i])
                        $("#dpId").append("<option value='"+data.list[i].id+"'>"+data.list[i].departmentName+"</option>");
                    }

                }
            }})
    });
    $("#serch").click(function() {
        $("#search-form2").submit();
    });
    $().ready(function() {
        $("#add").click(function() {
            location.href = 'activityAdd';
        });

        $(".del").click(function() {
            if (confirm('确定删除内容吗？')) {
                let id = $(this).data('id');
                $.ajax({
                    url : 'deleteActivity?activityId=' + id,
                    success : function(e) {
                        if (e.res) {
                            $("#tr_" + id).remove();
                            layer.msg('删除成功', {icon: 1})
                        }
                    },error:function(e){
                        layer.msg(e.responseText, {icon: 5});
                    }
                });
            }

        });
    });
    loadPage=function(){
        window.parent.loadPage();
    }
</script>
</body>
</html>
